<?php
//Start de sessie
session_start();

// Database connection
include 'includes/connect.php';

// Encodeer het id-nummer uit de URL
if(isset($_GET['id']) && is_numeric($_GET['id']))
{
    $id=$_GET['id'];
    // Retrieve all the data from the table
    $result = mysql_query("SELECT * FROM product WHERE productid='".$id."'")
    or die(mysql_error());
}

###########################################################################################
// Retrieve wishlist
$q1 = mysql_query("SELECT wishlist FROM klant WHERE klantid='".$_SESSION['klantid']."'")
or die(mysql_error());
$r1 = mysql_fetch_array( $q1 );
$neww = $r1['wishlist'];

    if($neww == $id)
    {
        $edit = $id;
    }
    else
    {
        $edit = ','.$id;
    }

    // id nummers verwijderen
    $newdel = str_replace($edit, "", $neww);
    $neww = $newdel;

    $test = "UPDATE klant SET wishlist='".$neww."' WHERE klantid='".$_SESSION['klantid']."'";
    $q2 = mysql_query($test)
    or die(mysql_error());

	header("Location: view_wishlist.php");
###########################################################################################

?>